]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
background: properly disconnect background signals
authorRay Strode <rstrode@redhat.com>
Tue, 19 Mar 2013 19:26:05 +0000 (15:26 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 26 Mar 2013 21:02:05 +0000 (17:02 -0400)
BackgroundManager connects to the changed signal in
the backgrounds it manages.

The signal ids for the changed signal connectionss are stored
as state on the background manager object.

If the background being managed changes while the manager
is still loading the old background, then the signal id
variable can get out of sync with the background object being
managed.

This commit ties the signal id to the background objects themselves,
so there is no opportunity for them to desynchronize.

https://bugzilla.gnome.org/show_bug.cgi?id=696157

js/ui/background.js

index e95cbc0a1ca4f8bfd546e7563544e2a74e6c743c..cacdffb0d14c013eb47de78e85aa930d0807fca6 100644 (file)
@@ -654,17 +654,9 @@ const BackgroundManager = new Lang.Class({
 
         this.background = this._createBackground();
         this._newBackground = null;
-        this._loadedSignalId = 0;
-        this._changedSignalId = 0;
     },
 
     destroy: function() {
-        if (this._loadedSignalId)
-            this._newBackground.disconnect(this._loadedSignalId);
-
-        if (this._changedSignalId)
-            this.background.disconnect(this._changedSignalId);
-
         if (this._newBackground) {
             this._newBackground.actor.destroy();
             this._newBackground = null;
@@ -683,22 +675,24 @@ const BackgroundManager = new Lang.Class({
         newBackground.saturation = background.saturation;
         newBackground.visible = background.visible;
 
-        let signalId = newBackground.connect('loaded',
+        newBackground.loadedSignalId = newBackground.connect('loaded',
             Lang.bind(this, function() {
-                newBackground.disconnect(signalId);
+                newBackground.disconnect(newBackground.loadedSignalId);
+                newBackground.loadedSignalId = 0;
                 Tweener.addTween(background.actor,
                                  { opacity: 0,
                                    time: FADE_ANIMATION_TIME,
                                    transition: 'easeOutQuad',
                                    onComplete: Lang.bind(this, function() {
-                                       this.background = newBackground;
-                                       this._newBackground = null;
-                                       background.actor.destroy();
+                                       if (this.background == background) {
+                                           this.background = newBackground;
+                                           this._newBackground = null;
+                                           background.actor.destroy();
+                                       }
                                        this.emit('changed');
                                    })
                                  });
         }));
-        this._loadedSignalId = signalId;
 
         this._newBackground = newBackground;
     },
@@ -717,12 +711,19 @@ const BackgroundManager = new Lang.Class({
             background.actor.lower_bottom();
         }
 
-        let signalId = background.connect('changed', Lang.bind(this, function() {
-            background.disconnect(signalId);
+        background.changeSignalId = background.connect('changed', Lang.bind(this, function() {
+            background.disconnect(background.changeSignalId);
+            background.changeSignalId = 0;
             this._updateBackground(background, this._monitorIndex);
         }));
 
-        this._changedSignalId = signalId;
+        background.actor.connect('destroy', Lang.bind(this, function() {
+            if (background.changeSignalId)
+                background.disconnect(background.changeSignalId);
+
+            if (background.loadedSignalId)
+                background.disconnect(background.loadedSignalId);
+        }));
 
         return background;
     },